﻿Imports System.IO



Public Class CommunicationService
    Inherits MarshalByRefObject
    Implements PassFiltInterface.ICommunicationService
    Private PolicyListDictionary As Concurrent.ConcurrentDictionary(Of String, String)
    Private PolicyCoverageDictionary As Concurrent.ConcurrentDictionary(Of String, String)
    Private PolicySettings As Concurrent.ConcurrentDictionary(Of String, DictionaryEntry)



    Public Function IManagedPasswordFilter(username As String, FullName As String, password As String, SetOperation As Boolean, MessageID As String, SequenceID As Long) As Boolean Implements PassFiltInterface.ICommunicationService.IManagedPasswordFilter
        WriteLog("Recieved Message, " & MessageID & "")
        Return True
    End Function

    Public Function IManagedPasswordChangeNotify(username As String, relativeid As Long, password As String, MessageID As String, SequenceID As Long) As Boolean Implements PassFiltInterface.ICommunicationService.IManagedPasswordChangeNotify
        WriteLog("Recieved Message, " & MessageID & "")
        Return True
    End Function



    Public Shared Sub WriteLog(ByVal msg As String)

        Dim DateString As String = DateTime.Now.ToString("d").Replace("/", "-")
        Dim MyPath As String = Path.GetDirectoryName(GetType(PassFiltService).Assembly.Location)
        Dim LogFolder As String = MyPath & "\PassFiltService"
        If Directory.Exists(LogFolder) = False Then
            Directory.CreateDirectory(LogFolder)
        End If

        Dim logFile As String = LogFolder & "\PassFiltService_" & DateString & ".Log"

        Dim fs1 As FileStream = New FileStream(logFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite)
        Dim s1 As StreamWriter = New StreamWriter(fs1)
        s1.WriteLine(Now & " ~ " & msg)
        s1.Close()
        fs1.Close()

    End Sub

End Class
